package edu.ccut.saturn.studio.validate.page;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.editor.FormPage;
import org.eclipse.ui.forms.widgets.ScrolledForm;

import edu.ccut.saturn.studio.validate.editor.ValidateEditor;
import edu.ccut.saturn.studio.validate.part.ValidatePart;

public class ValidatePage extends FormPage {

	public static final String PART_ID = "view";
	
	private final ValidateEditor editor;
	
	private ValidatePart validatePart; 
	
	public ValidatePage(ValidateEditor reditor) {
		super(reditor, PART_ID, "View");
		this.editor = reditor;
	}

	/**
	 * 创建本页的内容
	 */
	public void createFormContent(IManagedForm parent) {
		ScrolledForm form = parent.getForm();
		GridLayout layout = new GridLayout();
		form.getBody().setLayout(layout);
		createProperties();
	}
	
	/**
	 *创建properties属性部分
	 */
	private void createProperties(){
		Composite parent = getManagedForm().getForm().getBody();
		validatePart = new ValidatePart(parent, getManagedForm(), editor);
		validatePart.getSection().setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
		getManagedForm().addPart(validatePart);	
	}
	
	protected ValidateEditor getValidateEditor() {
		return editor;
	}
}
	